package com.wrx.swing.form;

import com.wrx.dto.generatesql.GenerateTotalInsertSqlByFileDto;

import javax.swing.*;

/**
 * SQL 生成表单字段管理类
 * 统一管理表单中的所有输入字段
 */
public class SqlGenerateFormFields {
    
    // 输入字段
    public final JTextField pointIdField = new JTextField();
    public final JTextField deviceIdField = new JTextField();
    public final JTextField devicePointIdField = new JTextField();
    public final JTextField factoryIdField = new JTextField();
    public final JTextField iotDeviceIdField = new JTextField();
    public final JTextField tenantIdField = new JTextField();
    public final JTextField dataBaseNameField = new JTextField();
    public final JTextField filePathField = new JTextField();
    
    // 日志区域
    public final JTextArea logArea = new JTextArea();
    
    public SqlGenerateFormFields() {
        // 文件路径字段设置为只读
        filePathField.setEditable(false);
    }
    
    /**
     * 从表单字段构建 DTO 对象
     */
    public GenerateTotalInsertSqlByFileDto buildDto() {
        GenerateTotalInsertSqlByFileDto dto = new GenerateTotalInsertSqlByFileDto();
        dto.setPointId(Integer.valueOf(pointIdField.getText()));
        dto.setDeviceId(Integer.valueOf(deviceIdField.getText()));
        dto.setDevicePointId(Integer.valueOf(devicePointIdField.getText()));
        dto.setFactoryId(Integer.valueOf(factoryIdField.getText()));
        dto.setIotDeviceId(iotDeviceIdField.getText());
        dto.setTenantId(Integer.valueOf(tenantIdField.getText()));
        dto.setDataBaseName(dataBaseNameField.getText());
        return dto;
    }
    
    /**
     * 获取文件路径
     */
    public String getFilePath() {
        return filePathField.getText();
    }
}

